AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: >-
  Lambda-based translation-server to run Zotero translators ({{ node_env }})
Resources:
  # Lambda function
  Lambda:
    Type: 'AWS::Serverless::Function'
    Properties:
      FunctionName: {{ main_function_name }}
      CodeUri: ./
      Handler: src/lambda.handler
      Runtime: nodejs8.10
      MemorySize: 2048
      Timeout: 30
      Policies:
        - LambdaInvokePolicy:
           FunctionName: {{ identifier_search_function_name }}
      Events:
        # API Gateway
        PostAPI:
          Type: Api
          Properties:
            # Proxy all POST requests to Lambda function
            Path: /{proxy+}
            Method: post
        OptionsAPI:
          Type: Api
          Properties:
            # Proxy all OPTIONS requests to Lambda function
            Path: /{proxy+}
            Method: options
      Environment:
        Variables:
          NODE_ENV: {{ node_env }}
Outputs:
  API:
    Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/"

